﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ExtractFanIn
{
    /// <summary>
    /// Author: Aaron Lumaksana
    /// Date: 16/08/10
    /// This class contains the main method where the code starts getting executed
    /// It handles the output to the console.
    /// </summary>
    class Program
    {

        static void Main(string[] args)
        {
            const int input = 0;
            const int output = 1;

            if (args.Length == 2)
            {
                NodeCollection lNodes = new NodeCollection();
                lNodes.Populate(args[input]);
                Console.WriteLine("Processed " + lNodes.LineCount + " lines in " + lNodes.Elapsed + "ms.");
                Console.WriteLine("#Source nodes: "+lNodes.NumberOfSource);
                Console.WriteLine("#Sink nodes: "+lNodes.NumberOfSink);
                Console.WriteLine("Max Fan-Out: "+lNodes.MaxFanOut);
                Console.WriteLine("Max Fan-In: " + lNodes.MaxFanIn);
                Console.WriteLine("number of nodes" + lNodes.numofnodes());
                lNodes.outputFanIn(args[output]);
                Console.WriteLine("Output written in " + lNodes.Elapsed + "ms.");
                
            }
            else
            {
                throw new Exception("Invalid number of arguments.. " + System.Environment.NewLine + "Syntax: ExtractFanIn SOURCE DEST");
            }

            
        }
    }
}
